
<template>
  <div class="project-add-container">
    <div class="header">
      <h3>修改项目</h3>
    </div>

    <!-- 步骤条保持 Element UI 的 el-steps -->
    <div class="steps-container">
      <el-steps :active="activeStep" finish-status="success">
        <el-step title="填写项目基本信息"></el-step>
        <el-step title="上传项目业主资料"></el-step>
      </el-steps>
    </div>

    <div class="form-container">
      <!-- 步骤1：填写项目基本信息 -->
      <div v-if="activeStep === 0">
        <!-- 选择方法学区域 -->
       <div class="form-section method-section">
  <label class="method-label">选择方法学<span class="required">*</span></label>
  <el-select
    class="method-value"
    placeholder="请选择方法学"
    style="width: 100%"
    v-model="projectForm.carbonMethodology"
  >
     <el-option
            v-for="item in methodology"
            :key="item.itemCh"  
            :label="item.itemCh" 
            :value="item.itemValue"
    ></el-option>
  </el-select>
</div>

        <!-- 项目信息区域 -->
        <div class="form-section">
          <h4 class="section-title">
            <i class="el-icon-info"></i> 项目信息
          </h4>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">项目<span class="required">*</span></label>
                <input class="info-value" v-model="projectForm.projectName" placeholder="输入项目名称" />
              </div>
            </el-col>
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">业主名称<span class="required">*</span></label>
                <input class="info-value" v-model="projectForm.ownerName" placeholder="输入业主名称" />
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">国家<span class="required">*</span></label>
                <el-select
                    class="method-value"
                    placeholder="请选择国家"
                     v-model="projectForm.country"
                    style="width: 100%">
                    <el-option
                            v-for="item in country"
                            :key="item.itemCh"  
                            :label="item.itemCh" 
                            :value="item.itemValue"
                    ></el-option>
                  </el-select>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">省份<span class="required">*</span></label>
               <el-select
                    class="method-value"
                     v-model="projectForm.province"
                    placeholder="请选择省份"
                    style="width: 100%">
                    
                    <el-option
                            v-for="item in provience"
                            :key="item.itemCh"  
                            :label="item.itemCh" 
                            :value="item.itemValue"
                    ></el-option>
                  </el-select>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">市/县/郡<span class="required">*</span></label>
                <input class="info-value" v-model="projectForm.city" placeholder="输入市/县/郡" />
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">项目地点<span class="required">*</span></label>
                <input class="info-value" v-model="projectForm.address" placeholder="输入项目地点" />
              </div>
            </el-col>
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">资产开发机构名称<span class="required">*</span></label>
                <input class="info-value" v-model="projectForm.assetsDevelopAgency" placeholder="输入资产开发机构名称" />
              </div>
            </el-col>
             <div class="info-row">
                <label class="info-label">项目类型<span class="required">*</span></label>
               <el-select
                    class="method-value"
                     v-model="projectForm.projectType"
                    placeholder="请选项目类型"
                    style="width: 100%">
                    
                    <el-option
                            v-for="item in projectType"
                            :key="item.itemCh"  
                            :label="item.itemCh" 
                            :value="item.itemValue"
                    ></el-option>
                  </el-select>
              </div>
          </el-row>
        </div>

        <!-- 项目介绍区域 -->
        <div class="form-section">
          <h4 class="section-title">
            <i class="el-icon-info"></i> 项目介绍
          </h4>
          <textarea 
            class="intro-content" 
            v-model="projectForm.projectIntroduction" 
            placeholder="输入项目介绍" 
            rows="4"
          ></textarea>
        </div>
      </div>

      <!-- 步骤2：上传项目业主资料 -->
      <div v-if="activeStep === 1">
        <div class="form-section">
          <h4 class="section-title"><i class="el-icon-info"></i> 基本信息</h4>
          <el-row :gutter="20">
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">业主法人姓名* </label>
                <input class="info-value"  v-model="projectForm.legalPersonName" placeholder="输入业主法人姓名" />
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">法人联系方式* </label>
                <input v-model="projectForm.legalPersonPhone" class="info-value" placeholder="输入法人联系方式" />
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">法人营业执照* </label>
                <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                   :file-list="YYZZRe"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadParamTranFile"
                 :on-preview="tranFilehandlePreview" 
                >
                  <el-button size="small" type="primary">选择文件</el-button>
                </el-upload>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">开发负责人姓名* </label>
                <input  v-model="projectForm.principalName" class="info-value" placeholder="输入负责人姓名" />
              </div>
            </el-col>
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">开发负责人电话* </label>
                <input v-model="projectForm.principalPhone" class="info-value" placeholder="输入负责人电话" />
              </div>
            </el-col>
          </el-row>
        </div>

        <div class="form-section">
          <h4 class="section-title"><i class="el-icon-info"></i> 材料信息</h4>
          <el-row :gutter="20">
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">项目核准/批复文件 </label>
                <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000003']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadXMHZFile"
                 :on-preview="tranFilehandlePreview" 
                >
                 <i style="margin-left: 30px;" class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">可行性研究报告 </label>
               <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000001']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadKXXYJFile"
                 :on-preview="tranFilehandlePreview" 
                >
                 <i style="margin-left: 13px;" class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">环评批复文件 </label>
               <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000004']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadHPPFFile"
                 :on-preview="tranFilehandlePreview" 
                >
              <i class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <div class="info-row">
                <label style="margin-left: -14px;" class="info-label">环评报告表 </label>
              <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                  :file-list="fileLists['0230000005']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadHPFile"
                 :on-preview="tranFilehandlePreview" 
                >
                <i class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">节能评估报告 </label>
               <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                  :file-list="fileLists['0230000006']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadJNPGFile"
                 :on-preview="tranFilehandlePreview" 
                >
                 <i class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">项目开工建设证明文件 </label>
               <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000007']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadXMKGJSFile"
                 :on-preview="tranFilehandlePreview" 
                >
               <i style="margin-left: 50px;" class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">项目投产证明文件 </label>
               <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000008']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadXMTCZMFile"
                 :on-preview="tranFilehandlePreview" 
                >
                 <i style="margin-left: 25px;" class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label  style="margin-left: -26px;" class="info-label">施工合同 </label>
                <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000010']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadSGHTFile"
                 :on-preview="tranFilehandlePreview" 
                >
                <i class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="info-row">
                <label class="info-label">主要设备购买合同 </label>
                <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                   :file-list="fileLists['0230000011']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadZYSBFile"
                 :on-preview="tranFilehandlePreview" 

                >
                <i style="margin-left: 25px;" class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="12">
              <div class="info-row">
                <label class="info-label">银行贷款合同/承诺书 </label>
               <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                 :file-list="fileLists['0230000012']"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadYHDKFile"
                 :on-preview="tranFilehandlePreview" 
                  
                >
                  <i style="margin-left: 40px;" class="el-icon-upload"></i>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="info-row">
               
                 <div class="info-row">
                <label  style="margin-left: -227px;" class="info-label">委托开发合同 </label>
                <el-upload
                  class="upload-demo"
                  ref="uploadHold"
                  :on-remove="removeFileList"
                  accept=".pdf,.docx,.xlsx,.xls,.jpg,.png"
                   style="width: 180px"
                  :action="upLoadParam.url"
                  :auto-upload="true"
                  :headers="{ token: upLoadParam.token }"
                  :on-success="upLoadWTKFHTFile"
                  :file-list="fileLists['0230000009']"
                 :on-preview="tranFilehandlePreview" 
                >
                  <i class="el-icon-upload"></i>
                </el-upload>
              </div>
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>

    <div class="buttons-container">
      <el-button v-if="activeStep === 1" @click="prevStep" class="prev-button">上一步</el-button>
      <el-button v-if="activeStep === 0" @click="nextStep" class="next-button">下一步</el-button>
      <el-button v-if="activeStep === 1" type="primary" @click="submitForm" class="submit-button">提交修改</el-button>
    </div>
  </div>
   
</template>

<script>
import {
  getFeiShuUpLoadProjectParams,
  getUpLoadFileParams,
} from "@/api/tenant";
export default {
  data() {
    return {
    Id0230000003: '', // 项目核准/批复文件
    Id0230000001: '', // 可行性研究报告
    Id0230000004: '', // 环评批复文件
    Id0230000005: '', // 环评报告表
    Id0230000006: '', // 节能评估报告
    Id0230000007: '', // 项目开工建设证明文件
    Id0230000008: '', // 项目投产证明文件
    Id0230000010: '', // 施工合同
    Id0230000011: '', // 主要设备购买合同
    Id0230000012: '', // 银行贷款合同/承诺书
    Id0230000009: '', // 委托开发合同（原有，保留）
      WTKFHTId:'',
      type : this.$route.query.type,
      rowId : this.$route.query.id,
      upLoadParams: {}, // 图片上传参数
      upLoadParam: {}, // 文件上传参数
      projectForm:{
        country:'',
        provience:'',
      },
       fileLists: {
      '0230000003': [], // 项目核准/批复文件
      '0230000001': [], // 可行性研究报告
      '0230000004': [], // 环评批复文件
      '0230000005': [], // 环评报告表
      '0230000006': [], // 节能评估报告
      '0230000007': [], // 项目开工建设证明文件
      '0230000008': [], // 项目投产证明文件
      '0230000010': [], // 施工合同
      '0230000011': [], // 主要设备购买合同
      '0230000012': [], // 银行贷款合同/承诺书
      '0230000009': [],  // 委托开发合同
    },
    
      fileRe:[],
      YYZZRe:[],
      activeStep: 0, 
      methodology:[],
      country:[],
      provience:[],
      projectType:[],
      user : JSON.parse(localStorage.getItem('user') || '{}'),
    }
  },

  mounted(){
     this.id = this.$route.query.id;
     this.loadInfo();
    this.loadSelectorData();
    this.upLoadParams = getUpLoadFileParams();
    this.upLoadParam = getFeiShuUpLoadProjectParams();
    this.loadFileList();
  },


  methods: {
    loadFileList() {
    this.$request.get('/assets/carbonProject/getFileList', {
      params: { projectId: this.id }
    }).then(res => {
      this.fileRe = res.data;
      // 清空原有列表
      Object.keys(this.fileLists).forEach(key => {
        this.fileLists[key] = [];
      });
      // 遍历文件列表，按fileDictValue分配到对应上传组件的file-list
      this.fileRe.forEach(file => {
        console.log("文件地址",file)
        const dictValue = file.fileDictValue;
        if (this.fileLists[dictValue]) {
          this['Id'+dictValue] = file.id;
          this.fileLists[dictValue].push({
            name: file.fileName, // 文件名
            url: file.url,   // 文件地址（用于预览）
            dictValue: file.fileDictValue,
            id: file.id || Date.now(), // 唯一标识（避免重复）
        
          });
        }
      });
    });
  },
   nextStep() {
    // 定义所有必填字段的验证规则：字段名 + 错误提示文字
    const requiredFields = [
      { field: 'carbonMethodology', label: '方法学' },
      { field: 'projectName', label: '项目名称' },
      { field: 'ownerName', label: '业主名称' },
      { field: 'country', label: '国家' },
      { field: 'province', label: '省份' },
      { field: 'address', label: '项目地点' },
      { field: 'projectType', label: '项目类型' }
    ];

    // 遍历验证所有必填字段
    for (const field of requiredFields) {
   
      if (!this.projectForm[field.field] || this.projectForm[field.field].trim() === '') {
        this.$message.error(`请填写/选择${field.label}`);
        return; // 只要有一个未填写，就阻止下一步
      }
    }

    // 所有必填项验证通过，进入下一步
    this.activeStep = 1;
  },

    loadInfo(){
      this.$request.get('/assets/carbonProject/queryBySelector2', {
        params: {  // 注意这里多了一层 params
        id: this.id,
         tenantId: this.user.tenantId
    }
      }).then(res => {
 
        if (res.code === 200) {
        // 假设响应数据格式与用户提供的一致
        const projectData = res.data.records[0];
        if(projectData){
          this.projectForm = {
            id: this.id,
            carbonMethodologyName: projectData.carbonMethodologyName,
            carbonMethodology: projectData.carbonMethodology,
            projectName: projectData.projectName,
            ownerName: projectData.ownerName,
            country: projectData.country,
            province: projectData.province,
            city: projectData.city,
            address: projectData.address,
            assetsDevelopAgency: projectData.assetsDevelopAgency,
            projectType: projectData.projectType,
            projectIntroduction: projectData.projectIntroduction,
            legalPersonName: projectData.legalPersonName,
            legalPersonPhone: projectData.legalPersonPhone,
            businessLicense: projectData.businessLicense,
            principalName: projectData.principalName,
            principalPhone: projectData.principalPhone
          };
          // 如果有文件列表数据，可以在这里处理
          // 例如：this.fileList = projectData.files || [];
          this.YYZZRe.push({
            url: projectData.businessLicense,   // 文件地址（用于预览）
          })
        }
        }
      })
    },
     
    prevStep() {
      this.activeStep = 0;
    },
//删除上传文件
    removeFileList(file, fileList) {
     let dictValue = file.dictValue || file.fileDictValue;
  if (dictValue && this.fileLists.hasOwnProperty(dictValue)) {
    // 3. 清空对应数组
    this.fileLists[dictValue] = [];
    this.$message.success(`已清空${dictValue}对应的文件列表`);
  } else {
    this.$message.error('未找到对应的文件列表');
    console.log('无法确定文件对应的dictValue:', file);
  }
    },
  //飞书回调预览
    tranFilehandlePreview(file) {
  // 兼容写法：先判断response是否存在，再获取msg
  console.log("看看回显里的url",file)
  let tranFileUrl;
  if (file.response && file.response.msg) {
    tranFileUrl = file.response.msg;
  } else {
    tranFileUrl = file.url;
  }
  
  if (tranFileUrl) {
    window.open(tranFileUrl, '_blank');
  } else {
    this.$message.error('文件地址不存在');
  }
},
    //飞书上传
     upLoadParamTranFile(response, file, fileList) {
      if (response) {
        this.projectForm.businessLicense = response.msg;

      }
    },
    // 1. 项目核准/批复文件（0230000003）
  upLoadXMHZFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000003',
        name: file.name,
        url: response.msg, // 统一字段名：url（与回显一致）
        tenantId: this.user.tenantId,
        id: this.Id0230000003, // 用回显的 Id 变量
        projectId: this.rowId
      };
      this.fileLists['0230000003'].push(newFileObj); // 加到对应数组
    }
  },

  // 2. 可行性研究报告（0230000001）
  upLoadKXXYJFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000001',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000001
      };
      this.fileLists['0230000001'].push(newFileObj);
    }
  },

  // 3. 环评批复文件（0230000004）
  upLoadHPPFFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000004',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000004
      };
      this.fileLists['0230000004'].push(newFileObj);
    }
  },

  // 4. 环评报告表（0230000005）
  upLoadHPFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000005',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000005
      };
      this.fileLists['0230000005'].push(newFileObj);
    }
  },

  // 5. 节能评估报告（0230000006）
  upLoadJNPGFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000006',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000006
      };
      this.fileLists['0230000006'].push(newFileObj);
    }
  },

  // 6. 项目开工建设证明文件（0230000007）
  upLoadXMKGJSFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000007',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000007
      };
      this.fileLists['0230000007'].push(newFileObj);
    }
  },

  // 7. 项目投产证明文件（0230000008）
  upLoadXMTCZMFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000008',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000008
      };
      this.fileLists['0230000008'].push(newFileObj);
    }
  },

  // 8. 施工合同（0230000010）
  upLoadSGHTFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000010',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000010
      };
      this.fileLists['0230000010'].push(newFileObj);
    }
  },

  // 9. 主要设备购买合同（0230000011）
  upLoadZYSBFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000011',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000011
      };
      this.fileLists['0230000011'].push(newFileObj);
    }
  },

  // 10. 银行贷款合同/承诺书（0230000012）
  upLoadYHDKFile(response, file, fileList) {
    if (response) {
      const newFileObj = {
        fileDictValue: '0230000012',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000012
      };
      this.fileLists['0230000012'].push(newFileObj);
    }
  },

  // 11. 委托开发合同（0230000009，原有，保留不变）
  upLoadWTKFHTFile(response, file, fileList) {
    if (response) { // 补充 response 判空（避免报错）
      const newFileObj = {
        fileDictValue: '0230000009',
        name: file.name,
        url: response.msg,
        tenantId: this.user.tenantId,
        id: this.Id0230000009
      };
      this.fileLists['0230000009'].push(newFileObj);
    }
  },
    submitForm() {
       
       this.$request.post('/assets/carbonProject/update',this.projectForm).then(res => {
        if(res.code === 200) {
            this.$request.post('/assets/carbonProject/updateFileList', this.fileLists ,{ 
    params: { 
      projectId: this.rowId 
    } 
  }
            )
        }
      })
      this.$message.success('项目修改成功');
       this.$router.push({
              path: '/carbon/projectCreate',
             
            })
    },
    loadSelectorData() {
      this.$request.get('/assets/carbonCreditAssets/querySelector').then(res => {
        if(res.code === 200) {  
          this.methodology = res.data.methodologyList;
          this.country = res.data.countryList;
          this.provience = res.data.provinceList;
          this.projectType = res.data.projectTypeList
        }
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.project-add-container {
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.upload-demo i.el-icon-upload {
  color: green; /* 设为绿色 */
  font-size: 25px;
  margin-top: 6px;
}

.header {
  margin-bottom: 20px;
  h3 {
    font-size: 18px;
    font-weight: 500;
    color: #333;
  }
}

.steps-container {
  margin-bottom: 30px;
  width: 70%; 
  margin-right: auto;
}

.form-container {
  .form-section {
    margin-bottom: 30px;
    padding: 30px;
    background-color: #f7f9fc;
    border-radius: 6px;

    .section-title {
      display: flex;
      align-items: center;
      margin-bottom: 20px;
      font-size: 16px;
      font-weight: 500;
      color: #424c5c;
      i {
        margin-right: 10px;
        color: #24a776;
      }
    }
  }

  // 选择方法学区域样式
  .method-section {
    display: flex;
    align-items: center;
    padding: 0 15px;
    height: 60px;
    margin-bottom: 25px;
    background-color: #f7f9fc;
    border-radius: 6px;

    .method-label {
      width: 90px;
      text-align: right;
      margin-right: 15px;
      color: #606266;
      font-size: 15px;
      font-weight: 500;
    }
    .method-value {
      flex: 1;
      min-width: 180px;
      max-width: 100%;
      width: 100%;
      border-radius: 6px;
      padding: 10px 12px;
      background-color: #fff;
      border: 1px solid #ccc; 
    }
    .required {
      color: #f56c6c;
      margin-left: 4px;
    }
  }

  // 项目信息区域样式
  .info-row {
    display: flex;
    align-items: flex-start;  // 修改为顶部对齐，防止元素高度变化影响
    width: 100%;
    margin-bottom: 15px;
    font-size: 15px;
    box-sizing: border-box;
    padding-top: 6px;  // 统一顶部内边距，保持标题对齐
    
    // 处理标签对齐
    .info-label {
      padding-top: 6px;  // 与输入框对齐
    }
    
    // 处理上传组件容器
    .upload-container {
      flex: 1;
      min-width: 180px;
    }
  }

  .info-label {
    width: 90px;
    text-align: right;
    margin-right: 15px;
    color: #606266;
    font-weight: 500;
    white-space: nowrap;
  }

  .required {
    color: #f56c6c;
    margin-left: 4px;
  }

  .info-value {
    flex: 1;
    min-width: 180px;
    max-width: 100%;
    max-width: 100%;
    width: 100%;
    padding: 10px 12px;
    background-color: #fff;
    border-radius: 7px;
    border: 1px solid #ccc; 
  }

  // 项目介绍内容样式
  .intro-content {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    resize: vertical;
  }
}

// 上传组件样式优化
.upload-demo {
  // 确保上传按钮与其他输入框对齐
  margin-top: -6px;
  
  // 控制文件列表样式，避免影响布局
  .el-upload-list {
    margin-top: 8px;
    width: 100%;
    max-width: 500px;  // 限制文件列表宽度
  }
  
  // 按钮样式微调
  .el-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

.buttons-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 30px;
  button {
    margin-left: 10px;
  }
  .prev-button {
    background-color: #fff;
    color: #606266;
    border-color: #dcdfe6;
  }
  .save-button {
    background-color: #fff;
    color: #606266;
    border-color: #dcdfe6;
  }
  .next-button {
    background-color: #24a776;
    border-color: #24a776;
    color: #fff;
  }
  .submit-button {
    background-color: #24a776;
    border-color: #24a776;
  }
}

.el-upload__tip {
  font-size: 12px;
  color: #909399;
  margin-top: 8px;
  display: block;
}

// 修复选择器与输入框样式一致性
::v-deep .el-select {
  .el-input {
    .el-input__inner {
      padding: 10px 12px;
      border-radius: 7px;
      border: 1px solid #ccc;
    }
  }
}
</style>
